﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PearTunes
{
	/// <summary>
	/// Interaction logic for MusicControlPro.xaml
	/// </summary>
	public partial class MusicControlPro : UserControl
	{
		
		
		public MusicControlPro()
		{
			this.InitializeComponent();
		}


        public static readonly RoutedEvent PlayButtonPressed =
            EventManager.RegisterRoutedEvent("PlayButtonPressed",
            RoutingStrategy.Bubble, typeof(RoutedEventHandler),
            typeof(MusicControlPro));

        public static readonly RoutedEvent NextButtonPressed =
            EventManager.RegisterRoutedEvent("NextButtonPressed",
            RoutingStrategy.Bubble, typeof(RoutedEventHandler),
            typeof(MusicControlPro));

        public static readonly RoutedEvent PrevButtonPressed =
            EventManager.RegisterRoutedEvent("PrevButtonPressed",
            RoutingStrategy.Bubble, typeof(RoutedEventHandler),
            typeof(MusicControlPro));

        public static readonly RoutedEvent PauseButtonPressed =
            EventManager.RegisterRoutedEvent("PauseButtonPressed",
            RoutingStrategy.Bubble, typeof(RoutedEventHandler),
            typeof(MusicControlPro));


        public event RoutedEventHandler PlayPressed
        {
            add { base.AddHandler(PlayButtonPressed, value); }
            remove { base.RemoveHandler(PlayButtonPressed, value); }
        }

        public event RoutedEventHandler NextPressed
        {
            add { base.AddHandler(NextButtonPressed, value); }
            remove { base.RemoveHandler(NextButtonPressed, value); }
        }

        public event RoutedEventHandler PrevPressed
        {
            add { base.AddHandler(PrevButtonPressed, value); }
            remove { base.RemoveHandler(PrevButtonPressed, value); }
        }

        public event RoutedEventHandler PausePressed
        {
            add { base.AddHandler(PauseButtonPressed, value); }
            remove { base.RemoveHandler(PauseButtonPressed, value); }
        }

       public static DependencyProperty PausedProperty =
            DependencyProperty.Register(
          "Pause Visible",
          typeof(bool),
          typeof(MusicControlPro),
          new FrameworkPropertyMetadata(
                new PropertyChangedCallback(ChangeToPaused)));

        public bool Pause
        {
            get
            {
                return (bool)GetValue(PausedProperty);
            }
            set
            {
                SetValue(PausedProperty, value);
            }
        }

        private static void ChangeToPaused(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            if ((bool)e.NewValue == true)
            {
                (source as MusicControlPro).Play_Normal.Visibility = Visibility.Hidden;
                (source as MusicControlPro).Play_Pressed.Visibility = Visibility.Hidden;
            }
            else
            {
                (source as MusicControlPro).Play_Normal.Visibility = Visibility.Visible;
                (source as MusicControlPro).Play_Pressed.Visibility = Visibility.Visible;
            }
        }

        private void Play_Normal_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            base.RaiseEvent(new RoutedEventArgs(PlayButtonPressed));
        }

        private void Prev_Normal_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            base.RaiseEvent(new RoutedEventArgs(PrevButtonPressed));
        }

        private void Next_Normal_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            base.RaiseEvent(new RoutedEventArgs(NextButtonPressed));
        }

        private void Pause_Normal_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            base.RaiseEvent(new RoutedEventArgs(PauseButtonPressed));
        }

	}
}